home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / a_man / cat7 / dlpi.z / dlpi
Encoding:
Text File  |  2002-10-03  |  18.3 KB  |  595 lines

  1.  
  2.  
  3.  
  4. DDDDLLLLPPPPIIII((((7777))))                                                                DDDDLLLLPPPPIIII((((7777))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      dlpi -  data link provider interface
  10.  
  11. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  12.      The DLPI is a kernel level interface, based on the STREAMS development
  13.      environment.  The DLPI interface is accessed from STREAMS protocol
  14.      modules via STREAMS messages or directly from user programs via the
  15.      putmsg(2) and getmsg(2) system calls.
  16.  
  17.      The Data Link Service (DLS) provider is configured as a STREAMS driver
  18.      and the DLS user accesses the provider using _o_p_e_n(2) /dev/llc2 (_l_l_c_2(7))
  19.      to establish a stream to the DLS provider.  The stream acts as a
  20.      communication endpoint between a DLS user and the DLS provider.  The
  21.      current implementation is a style 2 provider (a different minor device
  22.      for each DLS user) and is based on the DLPI Specification, Revision
  23.      2.0.0.
  24.  
  25.      Protocol stacks register themselves with DLPI which indicates the types
  26.      of packets which the stack will process.  The DLPI directs incoming
  27.      packets to the appropriate protocol stack.
  28.  
  29.      Outbound packets are directed to DLPI which sends them to the appropriate
  30.      MAC layer drivers i.e Ethernet, FDDI or Token Ring.
  31.  
  32.  
  33. CCCCOOOONNNNFFFFIIIIGGGGUUUURRRRAAAATTTTIIIIOOOONNNN
  34.      A.) Snif master file and interfaces
  35.  
  36.           The DLPI includes three master files: /var/sysgen/master.d/llc2,
  37.           /var/sysgen/master.d/xtimer, and /var/sysgen/master.d/snif. You
  38.           should not need to change the llc2 master file and the xtimer
  39.           master file. However, the snif master file provides a mapping
  40.           between the minor number of an interface and its name. The snif
  41.           master file shipped with the DLPI subsystem has three interfaces
  42.           pre-defined: one Token Ring interface, one Ethernet interface,
  43.           and one FDDI interface. The name of the interface should match to
  44.           the name as seen by _n_e_t_s_t_a_t -_i_a(1) command. The sequence of
  45.           the interfaces defined in the iftab[] table of the snif master
  46.           file determines the minor number of an interface (the major number
  47.           is always 117.)
  48.  
  49.           Upon installation the DLPI creates (_m_k_n_o_d(1M)) three devices
  50.           with minor numbers corresponding to the pre-defined interfaces
  51.           of the snif master file. If you must modify the snif master file,
  52.           be sure your interface name is a valid interface (can be seen by
  53.           the _n_e_t_s_t_a_t -_i_a command) and each interface in the iftab[]
  54.           table has its corresponding device defined. Please note that the
  55.           loopback interface, 'lo0' is not a valid interface for DLPI.
  56.           For example, to create a fv1 interface update the snif master
  57.           file iftab[] table with an entry for the fv1 device and issue the
  58.           command:
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. DDDDLLLLPPPPIIII((((7777))))                                                                DDDDLLLLPPPPIIII((((7777))))
  71.  
  72.  
  73.  
  74.              # mknod /dev/fv1 c 117 3
  75.  
  76.           In this example the minor number is 3 and the fv1 device would be
  77.           the fourth device listed in the iftab[] table (the device with the
  78.           minor device 0 is the first device listed in the iftab[] table.)
  79.  
  80.           After the installation of the DLPI software or after the snif
  81.           master file has been modified, you must _a_u_t_o_c_o_n_f_i_g(1M) to
  82.           create a new kernel and _r_e_b_o_o_t(1M) your kernel:
  83.  
  84.               # autoconfig -f
  85.               # reboot
  86.  
  87.  
  88.      B.) Snetd daemon and its config file
  89.  
  90.           Upon system startup, if the state of the DLPI daemon _s_n_e_t_d(1M)
  91.           is _o_n, the daemon is started by /etc/init.d/network. You may use
  92.           _c_h_k_c_o_n_f_i_g(1M) to check the state of the daemon, and use _i_f_c_o_n_f_i_g
  93.           (1M) to change its state.
  94.  
  95.           When the _s_n_e_t_d(1M) is started, it reads a configuration from
  96.           the /var/config/snetd.options file. Shipped with the software is a
  97.           sample snetd.options file that includes the sample configuration
  98.           lines for the three interfaces pre-defined in the snif master
  99.           file. As 'sample' configuration lines, the configuration lines are
  100.           commented out with an '#' sign at column one. To activate a
  101.           particular interface, the '#' signs must be removed. For example,
  102.           if your sample snetd.options is as below (Please note that the line
  103.           numbers will not be in the shipped file but they are put in here
  104.           for reference purposes):
  105.  
  106.      /*line1*/ #fv0    d       /dev/fv0
  107.      /*line2*/ #ec0    d       /dev/ec0
  108.      /*line3*/ #ipg0   d       /dev/ipg0
  109.      /*line4*/ llc2    dc      /dev/llc2
  110.      /*line5*/
  111.      /*line6*/ %%
  112.      /*line7*/
  113.      /*line8*/ #llc2   fv0     LL_SET_SNID=A   \
  114.      /*line9*/ #      SHELL="lltune -P -p llc2 -s A -d /dev/llc2 def.tokenring"
  115.      /*line10*/#llc2   ec0     LL_SET_SNID=B   \
  116.      /*line11*/#      SHELL="lltune -P -p llc2 -s B -d /dev/llc2 def.ether"
  117.      /*line12*/#llc2   ipg0    LL_SET_SNID=C   \
  118.      /*line13*/#      SHELL="lltune -P -p llc2 -s C -d /dev/llc2 def.fddi"
  119.  
  120.           To activate the ethernet interface ec0, you need only take out
  121.           the '#' sign at the beginning of the line #2, #10, and #11.
  122.  
  123.           Please also note that the LL_SET_SNID parameter is equivalent to
  124.           the Point of Physical Attachment (PPA) as referenced in the
  125.           DLPI Specification. The value 'B' is used in the DL_ATTACH_REQ
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. DDDDLLLLPPPPIIII((((7777))))                                                                DDDDLLLLPPPPIIII((((7777))))
  137.  
  138.  
  139.  
  140.          primitive, or in the case of 4DDN product, this value will be
  141.           used in the file '/var/opt/dn/dn_config' for the 'DPPA' parameter.
  142.  
  143.           If you add a new interface to the snif master file, you need to
  144.           create the configuration lines for the new interface as well. For
  145.           example, if you add fv1 as shown in the example of the "Snif master
  146.           file and interfaces" section, insert the following line between
  147.           line3 and line4:
  148.  
  149.               fv1    d       /dev/fv1
  150.  
  151.           and the next two lines after line13:
  152.  
  153.               llc2   fv1     LL_SET_SNID=D   \
  154.                     SHELL="lltune -P -p llc2 -s D -d /dev/llc2 def.tokenring"
  155.  
  156.           Please refer to the manual page _s_n_e_t_d(1M) for more information
  157.           on the configuration format. X.25 users should refer to its release
  158.           notes for a configuration utility that writes more X.25 related
  159.           configuration information into this snetd.options file.
  160.  
  161.  
  162. PPPPRRRRIIIIMMMMIIIITTTTIIIIVVVVEEEESSSS
  163.      The DLPI supports three modes of communication service: connection
  164.      (circuit-oriented), connectionless (message-oriented) and acknowledged
  165.      connectionless.  IRIX supports both  connection (DL_CODLS) service and
  166.      connectionless (DL_CLDLS) service.
  167.  
  168.      The following primitives are provided and are divided into the following
  169.      phases. More details may be found in <sys/dlpi.h> and the DLPI
  170.      Specification.
  171.  
  172.  
  173.      A.) Local Management
  174.  
  175.          1. Information Reporting Primitives
  176.           DL_INFO_REQ
  177.           DL_INFO_ACK
  178.           DL_ERROR_ACK
  179.  
  180.          2. Attach Primitives
  181.           DL_ATTACH_REQ
  182.           DL_DL_DETACH_REQ
  183.           DL_OK_ACK
  184.           DL_ERROR_ACK
  185.  
  186.          3. Bind Primitives
  187.           DL_BIND_REQ
  188.           DL_BIND_ACK
  189.           DL_SUBS_BIND_REQ
  190.           DL_SUBS_BIND_ACK
  191.           DL_UNBIND_REQ
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. DDDDLLLLPPPPIIII((((7777))))                                                                DDDDLLLLPPPPIIII((((7777))))
  203.  
  204.  
  205.  
  206.          DL_SUBS_UNBIND_REQ
  207.           DL_OK_ACK
  208.           DL_ERROR_ACK
  209.  
  210.          4. Other Primitives
  211.           DL_ENABMULTI_REQ
  212.           DL_DISABMULTI_REQ
  213.           DL_OK_ACK
  214.           DL_ERROR_ACK
  215.           DL_PHYS_ADDR_REQ
  216.           DL_PHYS_ADDR_ACK
  217.           DL_SET_PHYS_ADDR_REQ
  218.  
  219.      B.) Connection Establishment
  220.  
  221.          1. Connection Establishment Primitives
  222.           DL_CONNECT_REQ
  223.           DL_CONNECT_IND
  224.           DL_CONNECT_RES
  225.           DL_CONNECT_CON
  226.           DL_DISCONNECT_REQ
  227.           DL_DISCONNECT_IND
  228.           DL_TOKEN_REQ
  229.           DL_TOKEN_ACK
  230.           DL_OK_ACK
  231.           DL_ERROR_ACK
  232.  
  233.      C.) Connection-mode Data Transfer
  234.  
  235.          1. Data Transfer
  236.           To send an connection-mode data frame, a message consisting of one
  237.           or more M_DATA message blocks needs to be sent to the DLS
  238.           provider. This will cause an I-frame to be sent over the network,
  239.           containing the data passed in the M_DATA message blocks.
  240.           Incoming connection-mode data will be passed upstream in
  241.           messages consisting of one or more M_DATA message blocks.
  242.  
  243.          2. Reset Primitives
  244.           DL_RESET_REQ
  245.           DL_RESET_IND
  246.           DL_RESET_RES
  247.           DL_RESET_CON
  248.           DL_OK_ACK
  249.           DL_ERROR_ACK
  250.  
  251.      D.) Connection Release
  252.  
  253.          1. Connection Release Primitives
  254.           DL_DISCONNECT_REQ
  255.           DL_DISCONNECT_IND
  256.           DL_OK_ACK
  257.           DL_ERROR_ACK
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. DDDDLLLLPPPPIIII((((7777))))                                                                DDDDLLLLPPPPIIII((((7777))))
  269.  
  270.  
  271.  
  272.      E.) Connectionless-mode Data Transfer
  273.  
  274.          1. Data Transfer Primitives
  275.           DL_UNITDATA_REQ
  276.           DL_UNITDATA_IND
  277.  
  278.          2. Error Reporting Primitives
  279.           DL_UDERROR_IND
  280.  
  281.      F.) XID and TEST Services
  282.  
  283.          1. XID Primitives
  284.           DL_XID_REQ
  285.           DL_XID_IND
  286.           DL_XID_RES
  287.           DL_XID_CON
  288.  
  289.          2. TEST Primitives
  290.           DL_TEST_REQ
  291.           DL_TEST_IND
  292.           DL_TEST_RES
  293.           DL_TEST_CON
  294.  
  295.  
  296. DDDDLLLLSSSSAAAAPPPP AAAADDDDDDDDRRRREEEESSSSSSSS FFFFOOOORRRRMMMMAAAATTTTSSSS
  297.      A DLS user's identity is established by associating it with a DLS access
  298.      point (DLSAP), which is the point through wich the user will communicate
  299.      with the DLS provider. A DLSAP is identified by a DLSAP address.  A DLSAP
  300.      address contains the hardware address (usually 6 bytes in length)
  301.      followed by SAP information. Only the SAP information is needed to build
  302.      a DL_BIND_REQ primitive. The full DLSAP address is then returned to the
  303.      DLS users in the DL_BIND_ACK primitive and should be used where a DLSAP
  304.      address is required to construct a DLPI primitive as specified in the
  305.      DLPI Specification.
  306.  
  307.      802.2 LLC has two modes of operation to support the various types of SAP
  308.      that a DLS user may request. The mode of operation of a DLS user is
  309.      determined by the contents of the SAP information provided in the
  310.      DL_BIND_REQ primitive.  The modes of operation should not be confused
  311.      with the three modes of 802.2 LLC communication service; namely,
  312.      connection service mode, connectionless service mode and acknowledge
  313.      connectionless service mode.
  314.  
  315.      A.) Normal Mode
  316.  
  317.           The Normal mode of operation is when a bind is performed
  318.           with the value of the SAP information being in range 0x02
  319.           to 0xFE (a one-byte, even value). This is the SAP as
  320.           specified under 802.2 LLC, and is the only mode of operation
  321.           for the connection (i.e. LLC2) service mode. The
  322.           Sub-Network Access Protocol (SNAP) also uses this mode of
  323.           operation.
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. DDDDLLLLPPPPIIII((((7777))))                                                                DDDDLLLLPPPPIIII((((7777))))
  335.  
  336.  
  337.  
  338.           The DLSAP addresses for Normal mode have the following format:
  339.  
  340.           struct llc_dlsap {
  341.              u_char  dl_mac[6];     /* hardware address */
  342.              u_char  dl_sap;        /* LLC SAP          */
  343.           };
  344.  
  345.           The DLSAP address may be modified through DL_SUBS_BIND_REQ
  346.           primitive when the SNAP is used to extend the LLC header.
  347.           The extended SNAP DLSAP addresses have the following format:
  348.  
  349.           struct llc_snap_dlsap {
  350.              u_char  dl_mac[6];     /* hardware address */
  351.              u_char  dl_sap;        /* SNAP sap: 0xAA   */
  352.              u_char  dl_oui[3];     /* OUI information  */
  353.              u_char  dl_proto[2];   /* protocol ID      */
  354.           };
  355.  
  356.           DLS users should use llc_dlsap format in constructing the
  357.           DL_UNITDATA_REQ primitive and it is DLS users' responsibility
  358.           to put the OUI information and protocol ID in front of their
  359.           data. Upon receipt of DL_UNITDATA_IND, the DLSAP addresses
  360.           are also of llc_dlsap format. It is DLS users' responsibility
  361.           to skip the OUI information and protocol ID for users' data.
  362.  
  363.           The DLSAP address may also be modified if source routing is
  364.           used for Token Ring networks through TEST and/or XID
  365.           primitives. The source routing information field (rif) is
  366.           appended to the end of the llc_dlsap format. The DL_CONNECT_*
  367.           primitives should also use this llc_sri_dlsap format when
  368.           source routing information is present. The extended SRI
  369.           DLSAP addresses have the following format:
  370.  
  371.           struct llc_sri_dlsap {
  372.              u_char  dl_mac[6];     /* hardware address */
  373.              u_char  dl_sap;        /* LLC SAP          */
  374.              u_char  dl_rif;        /* start of rif     */
  375.           };
  376.  
  377.      B.) Ethernet Mode
  378.  
  379.           The Ethernet mode of operation occurs when a bind is performed
  380.           for two bytes (the high byte being non-zero). When this occurs
  381.           the binding driver will be sent packets for the Ethernet types
  382.           registered for.
  383.  
  384.           The DLSAP addresses for Ethernet mode have the following format:
  385.  
  386.           struct llc_eth_dlsap {
  387.              u_char  dl_mac[6];     /* hardware address */
  388.              u_short dl_sap;        /* Ethernet SAP     */
  389.           };
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. DDDDLLLLPPPPIIII((((7777))))                                                                DDDDLLLLPPPPIIII((((7777))))
  401.  
  402.  
  403.  
  404. EEEEXXXXAAAAMMMMPPPPLLLLEEEE
  405.      The example program below will format an DL_INFO_REQ message and send it
  406.      to the provider opened via the open(2) system call.  It will then check
  407.      for a valid response; if one is found, it will print the DLPI provider
  408.      style to the console.
  409.  
  410.      #include <stdio.h>
  411.      #include <fcntl.h>
  412.      #include <errno.h>
  413.      #include <sys/stream.h>
  414.      #include <sys/stropts.h>
  415.      #include <sys/dlpi.h>
  416.  
  417.      #define DLPIDEV          "/dev/llc2"
  418.  
  419.      int
  420.      main(int argc, char **argv)
  421.      {
  422.           int  fd;
  423.  
  424.           if ((fd = open(DLPIDEV, O_RDWR)) < 0 ) {
  425.                perror ("open");
  426.                exit(0);
  427.           }
  428.  
  429.           if (info(fd) < 0) {
  430.                perror ("info");
  431.                exit (0);
  432.           }
  433.  
  434.           close(fd);
  435.      }
  436.  
  437.  
  438.      int
  439.      print_info(dl_info_ack_t *info)
  440.      {
  441.           printf("DLPI Provider Style %d\n",
  442.                (info->dl_provider_style == DL_STYLE1) ? 1 : 2);
  443.      }
  444.  
  445.      int
  446.      info(int fd)
  447.      {
  448.           dl_info_req_t  info_req;
  449.           dl_info_ack_t  *info_ack;
  450.           dl_error_ack_t *error_ack;
  451.           struct strbuf  ctlbuf;
  452.           int       flags;
  453.           char      buffer[BUFSIZ];
  454.           char      *cp = buffer;
  455.           int       len;
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. DDDDLLLLPPPPIIII((((7777))))                                                                DDDDLLLLPPPPIIII((((7777))))
  467.  
  468.  
  469.  
  470.           /* Build info_req primitive */
  471.           info_req.dl_primitive = DL_INFO_REQ;
  472.  
  473.           ctlbuf.len = DL_INFO_REQ_SIZE;
  474.           ctlbuf.buf = (char *)&info_req;
  475.           flags = RS_HIPRI;
  476.  
  477.           if (putmsg(fd, &ctlbuf, NULL, flags ) < 0 )
  478.                return(-1);
  479.  
  480.           /*
  481.            * Now wait for the reply, this should be
  482.            * dl_info_ack or dl_error_ack
  483.            */
  484.           ctlbuf.maxlen = sizeof(buffer);
  485.           ctlbuf.len = 0;
  486.           ctlbuf.buf = buffer;
  487.           flags = RS_HIPRI;
  488.  
  489.           if (getmsg(fd, &ctlbuf, NULL, &flags) < 0)
  490.                return(-1);
  491.  
  492.           /* Is what we got sensible? */
  493.           if (ctlbuf.len < sizeof(long)) {
  494.                errno = EPROTO;
  495.                return(-1);
  496.           }
  497.  
  498.           /* Switch on type */
  499.           switch (*(unsigned long *)cp){
  500.           default:
  501.                errno = EPROTO;
  502.                return(-1);
  503.           case DL_INFO_ACK:
  504.                info_ack = (dl_info_ack_t *)cp;
  505.                print_info(info_ack);
  506.                return(fd);
  507.           case DL_ERROR_ACK:
  508.                if (ctlbuf.len < DL_ERROR_ACK_SIZE) {
  509.                     errno = EPROTO;
  510.                     return(-1);
  511.                }
  512.                error_ack = (dl_error_ack_t *)cp;
  513.                errno = error_ack->dl_unix_errno;
  514.                return(-1);
  515.           }
  516.      }
  517.  
  518. FFFFIIIILLLLEEEESSSS
  519.      <sys/dlpi.h>,
  520.  
  521.  
  522.  
  523.  
  524.  
  525.                                                                         PPPPaaaaggggeeee 8888
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. DDDDLLLLPPPPIIII((((7777))))                                                                DDDDLLLLPPPPIIII((((7777))))
  533.  
  534.  
  535.  
  536. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  537.      snetd(1M), chkconfig(1M), ifconfig(1M), llc2(7)
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.                                                                         PPPPaaaaggggeeee 9999
  592.  
  593.  
  594.  
  595.